math

Please click on ads to support us..

C++ Code:

#include <bits/stdc++.h>

using namespace std;
typedef long long ll;
#define fast ios::sync_with_stdio(0);cin.tie(0);cout.tie(0);
#define stream(line) istringstream in((line))
#define endl "\n"
#define F first
#define S second
#define clr(a, d) memset((a),d,sizeof(a))
const int MOD = 1e9 + 7;
const int N = 1e6 + 5;
const int M = 100 + 5;

void print_vector(vector<int> &v) {
    for (ll i = 0; i < v.size(); ++i) {
        cout << v[i] << " ";
    }
    cout << endl;
}

int main() {
    fast
    int tc = 1;
    string s = "314159265358979323846264338327";
    cin >> tc;
    while (tc--) {
        string t;
        cin >> t;
        int cnt =0;
        for (int i = 0; i < t.size(); ++i) {
            if(s[i] == t[i]){
                cnt++;
            }else{
                break;
            }
        }

        cout << cnt << endl;
    }
    return 0;
}


Comments

Submit
0 Comments
More Questions

766A - Mahmoud and Longest Uncommon Subsequence
701B - Cells Not Under Attack
702A - Maximum Increase
1656D - K-good
1426A - Floor Number
876A - Trip For Meal
1326B - Maximums
1635C - Differential Sorting
961A - Tetris
1635B - Avoid Local Maximums
20A - BerOS file system
1637A - Sorting Parts
509A - Maximum in Table
1647C - Madoka and Childish Pranks
689B - Mike and Shortcuts
379B - New Year Present
1498A - GCD Sum
1277C - As Simple as One and Two
1301A - Three Strings
460A - Vasya and Socks
1624C - Division by Two and Permutation
1288A - Deadline
1617A - Forbidden Subsequence
914A - Perfect Squares
873D - Merge Sort
1251A - Broken Keyboard
463B - Caisa and Pylons
584A - Olesya and Rodion
799A - Carrot Cakes
1569B - Chess Tournament